// Food.cpp: implementation of the Food class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "test.h"
#include "Food.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CFood::CFood()
{
	this->width  = 10;
	this->height = 10;
}

void CFood::DrawFood(CDC* pDC)
{
	int x;
	int y;
	CBrush brush(RGB(0, 255, 0));
	CBrush *pOldBrush;
	CPen   pen(PS_SOLID, 1, RGB(255, 0, 0));
	CPen   *pOldPen;

	pOldBrush = pDC->SelectObject(&brush);
	pOldPen   = pDC->SelectObject(&pen);
	
	x = this->position.x;
	y = this->position.y;

	pDC->Rectangle(x, y, x + 10, y + 10);

	pDC->SelectObject(pOldBrush);
	pDC->SelectObject(pOldPen);
}

CPoint CFood::GetPositon()
{
	return this->position;
}

void CFood::SetPosition(CPoint position)
{
	this->position = position;
}

void CFood::MakePoint(CPoint &point)
{
	int x;
	int y;

	srand((unsigned)time(NULL));

	x = 50 + 10 * (rand() % 40);
	y = 50 + 10 * (rand() % 40);

	point.x = x;
	point.y = y;
	
	TRACE("new food pos: x = %d, y = %d\n", x, y);
}


CFood::~CFood()
{

}
